<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>采购入库</title>
	<!-- import css and js --> 
	<%@ include file="/common/metaInput.jsp" %>  
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${ctx}/js/jsp/yd/logic/ItemStateData.js"></script>
	<script src="${ctx}/js/jsp/date.js" type="text/javascript"></script>
<script type="text/javascript">
var basic_Url="${ctx}/yd/logic/poware";
var grid;
var url;
var gridfreig;
var ItemStateList = ItemStateData.Rows;
var i =0;
var s =0;
$(function(){
	var column1 =  [
				{ display: '操作',width: 30,
				    render: function (record, rowindex, value, column) {
				  	  var rc = JSON.stringify(record);
				  	  if(record.openBatch=='Y'){
				  		 return "<a href='javascript:ItemWindow("+rc+","+rowindex+")'><img src='${ctx}/js/ligerUI/skins/icons/add.gif' alt='添加' /></a>";
				  	  }else{
				  		 return "<h1>+</h1>";
				  	  }
					  }},
					  { display: 'id', name: 'id', hide:1 },
					  { display: '物料id', name: 'materialsid', hide:1 },
					  { display: '<font color="gray">物料编码</font>', name: 'code', width: 120,
						  render: function (record, rowindex, value, column) {
							  var rc = JSON.stringify(record);
							  if(record.openBatch=='Y'){
								  return "<a href='javascript:ItemWindow("+rc+","+rowindex+")'>"+record.code+"</a>";
							  	  }else{
							  		 return record.code;
							  	  }
						  	  
						  }},
	                  { display: '<font color="gray">物料名称</font>', name: 'name', width: 180 },
	                  { display: '<font color="gray">描述</font>', name: 'spec', width: 245 },
// 		               { display: '批次<font color="red">*</font>', name: 'batch' ,width: 150,editor: { type: 'text'}},
						{ display: '<font color="gray">物料是否可用批次</font>', name: 'openBatch' ,hide:true,width: 150, render: function (item, rowindex, value, column)
												    {
								            	   	if(item.openBatch=="Y"){
								            	   		return "可用";
								            	   	}else{
								            	   		return "不可用";
								            	   	}
											   		
										    }},
	                  { display: '<font color="gray">基本单位单价</font>', name: 'price', width: 120},
	                  { display: '<font color="gray">基本单位</font>', name: 'junit', width: 120},
	                  { display: '<font color="gray">基本单位订单数量</font>', name: 'healthycount', width: 120},
	                  { display: '单位<font color="red">*</font>', name: 'unit', width: 120,editor : {
	                	  type:'selecturl',dataItem:'dataItem',path:'${ctx}/yd/basic/measurementUnit/unitlist.do',valueColumnName: 'unitname',displayColumnName: 'unitname', displayColumnName: 'unitname',onChanged:function(record,value,column,rowindex,datagrid){
	                	  grid.updateCell('itemBatchDO', '', record);
	                	  grid.updateCell('val', '', record);
	                	  grid.updateCell('jquantity', '', record);
	                	  grid.updateCell('quantity', '', record);
	                	  }}, render: function (item)
                           {
                	 		  var dataitem = $.parseJSON($("#dataItem").val());
                	 		  if(dataitem!=null){
                	 			 for (var i = 0; i < dataitem.length; i++)
                                 {
                                     if (dataitem[i]['unitname'] == item.unit&&dataitem[i]['materialscode']==item.code){
                                   	  	 grid.updateCell('unitconvert', dataitem[i]['unitconvert'], item);
                                   	  	 return dataitem[i]['unitname'];
                                        
                                     } 
                                 }
                	 		  }
                               return item.unit;
                           }},
	                  { display: '<font color="gray">订单数量</font>', name: 'badcount', width: 120},
	                  { display: '状态<font color="red">*</font>', name: 'state', width: 120,editor: { type: 'select', data: ItemStateList, valueColumnName: 'ItemStateID', displayColumnName: 'ItemStateName',
	                	  ext :
             					function (rowdata)
 				                {
		          	   				return {
						                        onBeforeOpen: function(){
													if("Y"==rowdata.openBatch){
														$.dialog.alert("该物料可分批次不能选择等级");
														return false;
													}
						                    	}
		          	   				};
 				                }}, render: function (item)
		                   {
		                   for (var i = 0; i < ItemStateList.length; i++)
		                   {
		                       if (ItemStateList[i]['ItemStateID'] == item.state){
		                     	  return ItemStateList[i]['ItemStateName'];
		                       }
		                   }
		                   return item.state;
		               }},
	                  { display: '<font color="gray">基本单位已入库数量</font>', name: 'inCount', width: 120},
	                  { display: '<font color="gray">基本单位入库数量</font>', name: 'jquantity', width: 120},
	                  { display: '入库数量<font color="red">*</font>', name: 'quantity', width: 120
	                	  ,editor: { type: 'float'},render:function(item){
// 	                		  if(item.openBatch=="Y"){
// 			            	   		item.quantity=item.val;
// 			            	   	}else{
			                	  	if(item.quantity!=''&&item.quantity!=null&&item.unitconvert!=null&&item.unitconvert!=''){
			
			                		  grid.updateCell('jquantity', (item.quantity*(item.unitconvert)).toFixed(4), item);
			            	   		}
// 	               				}
	                		  if(item.quantity==null||item.quantity==""){
	    							return "";
	    					  }else{
	    							return (1*item.quantity).toFixed(4);
	    						}
	                	//	  return (item.quantity==undefined ? 0:(parseFloat(item.quantity)).toFixed(4));
	                	  }
	                	  },
                 { display: '生产/采购日期<font color="red">*</font>', name: 'scrq', width: 120,editor : {type :'scdate'},render: function (item)
		    					{
                			if(item.scrq!=''&&item.scrq!=null){
                	 		item.scrq=formatDate(new Date(item.scrq),"yyyy-MM-dd");
                			}
 							return item.scrq;	
					}},
	                  { display: '有效期<font color="red">*</font>', name: 'yxq', width: 120,editor : {type :'scdate'}, render: function (item)
	    					{
		                	  if(item.yxq!=''&& item.yxq!=null){
		                		  item.yxq=formatDate(new Date(item.yxq),"yyyy-MM-dd");
		                	  }
	   						if(item.scrq!=''&&item.scrq!=null&&item.yxq!=null&&item.yxq!=''){
	   							grid.updateCell('bzq', daysBetween(item.scrq,item.yxq), item);
	   						}
	   						if(item.yxq==''||item.yxq==null){
	    						return "";
	    					}else{
	    						return item.yxq;	
	    					}
						}},
		               { display: '<font color="gray">保质期(天)</font>', name: 'bzq', width: 120},
		               { display: '<font color="gray">单位换算率</font>', name: 'unitconvert', width: 120,render:function(item){
		            	   getBadcount(item);
		            	   return item.unitconvert;
		               }},
		               { display: '<font color="gray">值</font>', name: 'val' ,width:1,hide:1},
		               { display: '<font color="gray">详细批次</font>', name: 'itemBatchDO',hide:1},
		               { display: '<font color="gray">删除批次记录</font>', name: 'delItemBatchDO',hide:1}
// 		               { display: '分多批操作',width: 150,
// 	              	        render: function (record, rowindex, value, column) {
// 	              		  	   return "<a href='javascript:manyBatch(" + rowindex + ")'>分多批次</a>";
// 	              		  }}
	                  ];
	var column2 =  [
				{ display: '操作',width: 30,
				    render: function (record, rowindex, value, column) {
				  	  var rc = JSON.stringify(record);
				  	  if(record.openBatch=='Y'){
				  		 return "<a href='javascript:ItemWindow("+rc+","+rowindex+")'><img src='${ctx}/js/ligerUI/skins/icons/add.gif' alt='添加' /></a>";
				  	  }else{
				  		 return "<h1>+</h1>";
				  	  }
					  }},
					  { display: 'id', name: 'id', hide:1 },
					  { display: '物料id', name: 'materialsid', hide:1 },
					  { display: '<font color="gray">物料编码</font>', name: 'code', width: 120,
						  render: function (record, rowindex, value, column) {
							  var rc = JSON.stringify(record);
							  if(record.openBatch=='Y'){
								  return "<a href='javascript:ItemWindow("+rc+","+rowindex+")'>"+record.code+"</a>";
							  	  }else{
							  		 return record.code;
							  	  }
						  	  
						  }},
	                  { display: '<font color="gray">物料名称</font>', name: 'name', width: 180 },
	                  { display: '<font color="gray">描述</font>', name: 'spec', width: 245 },
//   		               { display: '批次<font color="red">*</font>', name: 'batch' ,width: 150},
						{ display: '<font color="gray">物料是否可用批次</font>', name: 'openBatch' ,hide:true,width: 150, render: function (item, rowindex, value, column)
						    {
		            	   	if(item.openBatch=="Y"){
		            	   		return "可用";
		            	   	}else{
		            	   		return "不可用";
		            	   	}
					   		
				    	}},
	                  { display: '<font color="gray">基本单位单价</font>', name: 'price', width: 120},
	                  { display: '<font color="gray">基本单位</font>', name: 'junit', width: 120},
	                  { display: '<font color="gray">基本单位订单数量</font>', name: 'healthycount', width: 120},
	                  { display: '单位<font color="red">*</font>', name: 'unit', width: 120},
	                  { display: '<font color="gray">订单数量</font>', name: 'badcount', width: 120},
	                  { display: '状态<font color="red">*</font>', name: 'state', width: 120,
	                	  render: function (item){
	                		  var state=item.state;
	                		  if(state=="1"){
	                			  return "一等品";
	                		  }
	                		  if(state=="2"){
	                			  return "次品";
	                		  }
	                		  if(state=="3"){
	                			  return "旧件";
	                		  }
	                	  }},
	                  { display: '<font color="gray">基本单位已入库数量</font>', name: 'inCount', width: 120},
	                  { display: '<font color="gray">基本单位已退货数量</font>', name: 'jreturnCount', width: 120},
	                  { display: '<font color="gray">基本单位入库数量</font>', name: 'jquantity', width: 120},
	                  { display: '<font color="gray">入库数量</font>', name: 'quantity', width: 120},
	                  { display: '生产/采购日期<font color="red">*</font>', name: 'scrq', width: 120,render: function (item)
	    					{
              			if(item.scrq!=''&&item.scrq!=null){
              	 		item.scrq=formatDate(new Date(item.scrq),"yyyy-MM-dd");
              			}
							return item.scrq;	
					}},
	                  { display: '有效期<font color="red">*</font>', name: 'yxq', width: 120, render: function (item)
    					{
	                	  if(item.yxq!=''&& item.yxq!=null){
	                		  item.yxq=formatDate(new Date(item.yxq),"yyyy-MM-dd");
	                	  }
    						return item.yxq;	
					}},
	                  { display: '<font color="gray">保质期(天)</font>', name: 'bzq', width: 120},
	                  { display: '<font color="gray">单位换算率</font>', name: 'unitconvert', width: 120},
	                  { display: '<font color="gray">值</font>', name: 'val' ,width:1,hide:1},
	                  { display: '<font color="gray">详细批次</font>', name: 'itemBatchDO',hide:1},
	                  { display: '<font color="gray">删除批次记录</font>', name: 'delItemBatchDO',hide:1}
	                  ];
	var colunm3 = column1;                 
    if('${poware.billstatus}' != "" && '${poware.billstatus}' != "0"){
    	colunm3 = column2;    
    }
    var griddata ={};
	grid = $("#table1").ligerGrid({
        columns: colunm3,
                  enabledEdit: true,
                  usePager: true,pageSize:1000,pageSizeOptions:[1000],
                  //data : griddata,
                  parms:[{ name : 'id' , value : '${poware.id}'}],
                  url : basic_Url+"/griditems.do",
                  width: "100%", height:250, checkbox: true,rownumbers:true,
                  toolbar: { items: [
                                     { text: '删除', click: deleteRow, img: '${ctx}/js/ligerUI/skins/icons/delete.gif' }
                                     ]
                                     }
                  });
	
	$("#pageloading").hide();
	
	$("#inputForm").validate({			   
	onsubmit: true,
	 /*执行ajaxsubmit  */ 
    submitHandler: function(editform) {
        try{			    		
            url =  basic_Url+"/save.do";
            var api = frameElement.api;
        	var W = api.opener;
            getReturnMessage(url,"inputForm",W.searchAP);
        }catch(e){alert(e)}
    }
	});

	$("#storage").change(function(){ 
		  $("#whcode").val($("#storage").val());
		  $("#whname").val($("#storage").find("option:selected").text());
	}); 
	
	
	$("#apply").change(function(){ 
		if($("#apply").val()==""){
			$.dialog.alert("您选择的订单不能为空");
			return false;
		}
		$("#pocode").val($("#apply").find("option:selected").text());
		<c:forEach items='${polist}' var='state'>
        	if($("#apply").find("option:selected").text()=='${state.pocode}'){
        		$("#popattern").val('${state.popattern}');
        		$("#createname").val('${user.name}');
        		$("#spname").val('${state.spname}');
        		$("#spcode").val('${state.spcode}');
        		$("#depname").val('${state.depname}');
        		$("#depacode").val('${state.depacode}');
        	}
       	</c:forEach>
		multipleSearch("#table1",true,"",basic_Url+"/poitemlist.do?poid="+$("#apply").val());
	}); 
	
	if('${poware.billstatus}' != "" && '${poware.billstatus}' != "0"){
		$("input").attr("readonly","readonly");
		$("input").attr("onclick","");
		$("select").attr("disabled","disabled");
	}
	
	if('${poware.billstatus}' == ""){
// 		$("#saveWj").hide();//禁用保存按钮
		$("#save1").hide();//禁用保存按钮
		$("#save2").hide();//禁用保存按钮
		$("#save3").hide();//禁用保存按钮
		$("#bohui").hide();
		$("#savej2").hide();
		$("#excel").hide();
	}
	else if('${poware.billstatus}' == "0" ){
// 		$("#saveWj").hide();//禁用保存按钮
		if('${user.name}' != '${poware.dcruser}'){
			$("#save1").hide();
		}
		$("#save").hide();//禁用保存按钮
		$("#save2").hide();//禁用保存按钮
		$("#save3").hide();//禁用保存按钮
		$("#bohui").hide();
		$("#savej2").hide();
//		$("#excel").hide();
	}
	else if('${poware.billstatus}' == "1" ){
// 		$("#saveWj").hide();//禁用保存按钮
		$("#save1").hide();//禁用保存按钮
		$("#save").hide();//禁用保存按钮
		$("#save3").hide();//禁用保存按钮
//		$("#excel").hide();
	}
	else if('${poware.billstatus}' == "2"){
		$("#save1").hide();//禁用保存按钮
		$("#save2").hide();//禁用保存按钮
		$("#save").hide();//禁用保存按钮
		$("#savej2").hide();
//		$("#excel").hide();
	}
	else{
		$("#save").hide();//禁用保存按钮
// 		$("#saveWj").hide();//禁用保存按钮
		$("#save1").hide();//禁用保存按钮
		$("#save2").hide();//禁用保存按钮
		$("#save3").hide();//禁用保存按钮
		$("#bohui").hide();
		$("#savej2").hide();
	}
// 	if ('${flag}' == 'ADD'){
// 		 $("#tr1").hide();
// 		 $("#apply2").hide();
// 	}
	
// 	<c:forEach items='${wareitem}' var='item'>
//     	grid.addRow2({
//     		id: "${item.id}",
//     		materialsid: "${item.materialsid}",
//     		code: "${item.code}",
//     		name: "${item.name}",
//     		spec: "${item.spec}",
//     		junit : "${item.junit}",
//     		healthycount : "${item.healthycount}",
//     		unit : "${item.unit}",
//    	   		batch : "${item.batch}",
//     		badcount : "${item.badcount}",
//     		inCount : "${item.inCount}",
//     		jreturnCount : "${item.jreturnCount}",
//     		price : "${item.price}",
//     		jquantity : "${item.jquantity}",
//     		quantity : "${item.quantity}",
//     		state : "${item.state}",
//     		unitconvert : "${item.unitconvert}",
//     		itemBatchDO : '${item.itemBatchDO}',
//     		bzq : "${item.bzq}",
//     		scrq : new Date("${item.scrq}").formatdt('yyyy-MM-dd'),
//     		yxq : new Date("${item.yxq}").formatdt('yyyy-MM-dd'),
//     		openBatch: "${item.openBatch}",
//     		val : "${item.val}"
//         });
//     </c:forEach>
})
 function getBadcount(item){
   	if(undefined == item){
   		return;
   	}
   	if(!isNaN(item.healthycount) && item.healthycount!=null&&item.unitconvert!=null&&item.unitconvert!=''){
   		item.badcount = item.healthycount/parseFloat(item.unitconvert) ;
   	}else{
   		item.badcount=null;//清除值
   	}
}
function ItemWindow(rc,index) {
 	//alert("rc:"+rc+"明细:"+rc.toSource());
 	var manager = $("#table1").ligerGetGridManager();
//  	alert("aaaa:"+JSON.stringify(manager.getRow(rc.__index)));
		getDG().dialog(
				{
					title : '批次管理',
					width : 650,
					height : 350,
					content : 'url:' + sys_context+ '/yd/logic/poware/itemManager.do?data='+encodeURIComponent(JSON.stringify(manager.getRow(rc.__index)))+'&billstatus=${poware.billstatus}',//
					lock : true,
					max : true,
					min : true,
					ok : function() {
						this.content.yz();
						if(this.content.ba){
						var dt = this.content.grid.getData();
						var dtDel = this.content.grid.getDeleted();
						if (dt != null) {
							//alert("dt:"+dt.toSource());
							rc.jquantity=this.content.jnum;
							rc.quantity=this.content.num;
							rc.itemBatchDO=JSON.stringify(dt);
							rc.delItemBatchDO=JSON.stringify(dtDel);
// 							grid.deleteRow(index);
// 							grid.addRow(rc);
									
									grid.updateCell('jquantity', rc.jquantity, manager.getRow(rc.__index));
									grid.updateCell('quantity', rc.quantity, manager.getRow(rc.__index));
									grid.updateCell('val', rc.quantity, manager.getRow(rc.__index));
									grid.updateCell('itemBatchDO',rc.itemBatchDO, manager.getRow(rc.__index));
									grid.updateCell('delItemBatchDO',rc.delItemBatchDO, manager.getRow(rc.__index));
									grid.updateRow(manager.getRow(rc.__index));
									this.content.Close();
							}else{
								this.content.Close();
							}
							
						}
						return false;
					},
					cancelVal : '关闭',
					cancel : true
				}).zindex();
	}
function submitForm(param){
	var data = grid.getData();
	var dl=grid.getDeleted();
	if(data.length==0){
		$.dialog.alert("请选择申请物料");
   	 	return false;
	}
	var ba=true;
	if(data !=null){
		var i=0;
		$(data).each(function (){
			i++;
			
// 			if (isNaN(this.itemBatchDO) ||this.itemBatchDO==undefined ||this.itemBatchDO==null) {
// 				ba = false;
// 				$.dialog.alert("您第" + i + "行的物料没有分批次填写!");
// 				return false;
// 			}
// 			if(this.batch==undefined ||this.batch.replace(/(^\s*)|(\s*$)/g, "")=="" ||this.batch==null){
// 				ba = false;
// 				$.dialog.alert("您第" + i + "行的批次没有填写");
// 				return false;
// 			}
				if(this.openBatch != "Y"){
							if(this.state=="" ||this.state==undefined ||this.state==null){
								ba = false;
								$.dialog.alert("您第" + i + "行的状态没有填写");
								return false;
							}
				}
			if (isNaN(this.quantity) ||this.quantity==undefined ||this.quantity==null) {
				ba = false;
				$.dialog.alert("您第" + i + "行的数量没有填写");
				return false;
			}
			if (this.quantity <= 0) {
				$.dialog.alert("您第" + i + "行的入库数量不能小于等于0");
				ba = false;
				return false;
			}else{
				if (this.inCount == null){
					this.inCount = 0;
				}
				if (parseFloat(parseFloat(this.healthycount - this.inCount)).toFixed(4) < parseFloat(parseFloat(this.jquantity).toFixed(4))){
					$.dialog.alert("您第" + i + "行的入库数量大于订单未入库数量");
					ba = false;
					return false;
				}
			}
			if (isNaN(this.bzq) ||this.bzq==undefined ||this.bzq==null) {
				ba = false;
				$.dialog.alert("您第" + i + "行的保质期没有填写");
				return false;
			}
			if (this.scrq=="" ||this.scrq==null) {
				ba = false;
				$.dialog.alert("您第" + i + "行的生产日期没有填写");
				return false;
			}
			if (this.yxq=="" ||this.yxq==null) {
				ba = false;
				$.dialog.alert("您第" + i + "行的有效期没有填写");
				return false;
			}
			if (this.bzq<=0) {
				ba = false;
				$.dialog.alert("您第" + i + "行的保质期天数必须大于0");
				return false;
			}
			});
		}
		jQuery.ajaxSettings.async = false;
	if(param==3){
		getDG().dialog({content: "是否审核完结请选择(Yes或者No)!",width: 250,lock: true,max: false,min: false,
			title:'Confirm Infor',
			button: [
			         {
			             name: 'Yes',
			             callback: function(){
				            	 if (ba) {
				     				$("#type").val(param);
				     				$("#itemdata").val(JSON.stringify(data));
				     				$("#itemdelete").val(JSON.stringify(dl));
				     				$("#submitFlag").val(param);
				     				$("#inputForm").submit();
				     			}
				            }
			         },
			         {
			        	   name: 'No',
			        	   focus: true
			         }             
			     ]
		}).zindex();
		}else{
			if (ba) {
				$("#type").val(param);
				$("#itemdata").val(JSON.stringify(data));
				$("#itemdelete").val(JSON.stringify(dl));
				$("#submitFlag").val(param);
				$("#inputForm").submit();
			}
		}
	}

	function deleteRow() {
		if('${po.billstatus}' != "" && '${po.billstatus}' != "0"){
			return false;
		}else{
		grid.deleteSelectedRow();
		}
	}
	
	function exportAP(){
		var id=$("#id").val();
		if(id!=""){
			var path = basic_Url+"/exportExcel.do?id="+id;
	   		window.open(path,"_blank");
		}
		else{
			$.dialog.alert("请先保存再导出");
		}
	}
    
	/*计算两个日期之间的天数（含当天）*/
	function daysBetween(DateOne,DateTwo)
	{   
	    var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ('-'));  
	    var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ('-')+1);  
	    var OneYear = DateOne.substring(0,DateOne.indexOf ('-'));  
	  
	    var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ('-'));  
	    var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ('-')+1);  
	    var TwoYear = DateTwo.substring(0,DateTwo.indexOf ('-'));  
	  
	    var days=((Date.parse(TwoMonth+'/'+TwoDay+'/'+TwoYear) - Date.parse(OneMonth+'/'+OneDay+'/'+OneYear))/86400000)+1;  //包含当天
	    return days;
	}
	
// 	function bhcheck(){
// 		if($("#id").val()==""){
// 			$.dialog.alert("没有提交无法驳回");
// 			return false;
// 		}
// 		$.ajax({
// 	      	url: "${ctx}/yd/logic/poware/updateState.do",
// 	      	global: false,
// 	      	type: "POST",
// 	     	dataType: "json",
// 	      	data: ({
// 	    	  	rows : $("#id").val()
// 	      	}),		     
// 	      	success: function(msg){
// 	    	  	if(msg.msg=="SUCCESS"){
// 	    		  	$.dialog.alert("驳回成功");
// 	    	  	}
// 	    	  	if(msg.msg=="ERROR"){
// 	    		  	$.dialog.alert("驳回失败");
// 	    	  	}
// 	    	  	CloseDialog();
// 	    	  	var api = frameElement.api;
// 	         	var W = api.opener;
// 	            W.searchAP();
// 	   		}
// 		});
// 	}
</script>

</head>

<body>

<form id="inputForm" action="" method="post">
<!-- <input type="hidden" id="unitconvert" name="unitconvert" value=""/> -->
<input type="hidden" id="id" name="id" value="${poware.id}"/>
<input type="hidden" id="version" name="version" value="${poware.version}"/>
<input type="hidden" id="billtype" name="billtype" value="1"/>
<input type="hidden" id="profitand" name="profitand" value="0"/>
<input type="hidden" id="itemdata" name="itemdata" value=""/>
<input type="hidden" id="itemdelete" name="itemdelete" value=""/>
<input type="hidden" id="dataItem" name="dataItem"/>
<input type="hidden" id="yfitemdata" name="yfitemdata" value=""/>
<input type="hidden" id="yfitemdelete" name="yfitemdelete" value=""/>
<input type="hidden" id="type" name="type" value=""/>
<!-- 用于标识提交按钮 -->
<input type="hidden" id="submitFlag" value="" />
 <div class="pageContent" >
    <div class="panel">
         <table class="TableBlock" align="center">
<%--          <c:if test="${not empty  poware.powarecode}"> --%>
<!--                    <tr id="tr1"> -->
<!--                     <td nowrap>采购入库单号:</td> -->
<!--    		                 <td> -->
<%--    		                <input type="text" id="powarecode" name="powarecode" readonly="readonly" class="required" value="${poware.powarecode}" /> --%>
<!--    		                 </td> -->
<!--    		           </tr> -->
<%--    		  </c:if>          --%>
   		           <tr>
                    <c:choose>
                    	<c:when test="${empty poware.pocode}">
                    	<td nowrap>采购编号:</td>
	                    	<td>
	   		                 <select id="apply" name="apply" class="required  inp_width_98p">
	   		                 	<option></option>
	   		                 	<c:forEach items='${polist}' var='state'>
	   		                 	<option id="${ state.pocode}" value='${state.id}'>${state.pocode}</option>
	   		                 	</c:forEach>
	   		                 	</select>
	   		                 	<input type="hidden" id="pocode" name="pocode" value=""/>
	   		                 	<script type="text/javascript">
	   		                		 $("#"+'${poware.pocode}').attr("selected","selected");
	   		                 	</script>
	   		                 </td>
	   		                 <td colspan="2"></td>
                    	</c:when>
                    	<c:otherwise>
                    	<td nowrap>采购入库单号:</td>
   		                 <td>
   		                <input type="text" id="powarecode" name="powarecode" readonly="readonly" class="required  inp_width_98p" value="${poware.powarecode}" />
   		                 </td>
                    	<td nowrap>采购编号:</td>
	                    	<td colspan="3">
	   		                 	<input type="text"  id="pocode" name="pocode" value="${poware.pocode}" class="inp_width_98p" readonly="readonly"/>
	   		                 </td>
                    	</c:otherwise>
                    </c:choose>
   		                 
   		           </tr>
   		            <tr>
   		           <td nowrap>采购方式:</td>
   		                 <td>
   		                	<input  type="text" id="popattern" name="popattern"  class="required  inp_width_98p" value="${poware.popattern}" readonly="readonly"/>
   		                 </td>
   		                 <td nowrap>制单人:</td>
   		                 <td>
   		                	<input   type="text" id="createname" name="createname" class="required  inp_width_98p"  value="${poware.createname}" readonly="readonly"/>
   		                 </td>
   		           </tr>
   		           <tr>
   		            <td nowrap>供应商:</td>
                    	<td>
                    	<input type="hidden" id="spcode" name="spcode" class="required  inp_width_98p"  value="${poware.spcode}" readonly="readonly"/>
                    	<input type="text" id="spname" name="spname" class="required  inp_width_98p"  value="${poware.spname}" readonly="readonly"/>
                    	</td>
   		           <td nowrap>入库仓库:</td>
                    	<td><select id="storage" name="storage"  class="required  inp_width_98p">
   		                 	<option></option>
   		                 	<c:forEach items='${wh}' var='state'>
   		                 	<option id="${ state.code}" value='${state.code}'>${state.name}</option>
   		                 	</c:forEach>
   		                 	</select>
   		                 	<input type="hidden" id="whcode" name="whcode" value="${poware.whcode}"/>
   		                 	<input type="hidden" id="whname" name="whname" value="${poware.whname}"/>
   		                 	<script type="text/javascript">
   		                		 $("#"+'${poware.whcode}').attr("selected","selected");
   		                 	</script></td>
   		                
   		           </tr>
   		            <tr>
   		           <td nowrap>验收人:</td>
                    	<td>
                    	<input type="text" id="ysr" name="ysr"   class="required  inp_width_98p" value="${poware.ysr}"  />
                    	</td>
                    	<td nowrap>入库日期:</td>
   		                 <td>
   		                	<input type="text" id="rkdate" name="rkdate"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="required  inp_width_98p" value="<fmt:formatDate value="${poware.rkdate}" pattern="yyyy-MM-dd" type="both" />"  readonly="readonly"/>
   		                 </td>
   		                 <%-- <td nowrap>批次:</td>
   		                 <td>
   		                	<input type="text" id="batch" name="batch" style="width: 150px;"  class="required" value="${poware.batch}"  />
   		                 </td> --%>
   		           </tr>
   		           <tr>
   		                <td>部门:</td>
   		           		<td><input type="text"  id="depname" name="depname" class="inp_width_98p"  value="${poware.depname}"  readonly="readonly"/>
   		           		<input type="hidden"  id="depacode" name="depacode"   value="${poware.depacode}"/>
   		           		</td>
					</tr>
   		           <tr>
 		                 <td>备注:</td>
 		           		<td colspan="3"><input id="remark" class="inp_width_98p" name="remark" value="${poware.remark}" /></td>
   		           		
   		           </tr>
                </table>
                <div id="table1"> </div> 
                <div id="table2"> </div>               
         </div>
<div class="formBar">
	        <ul>
	         <li><div class="button"><div class="buttonContent"><button type="button" id="excel" class="export" onclick="exportAP()">导出</button></div></div> </li>
		       <li><div class="buttonActive"><div class="buttonContent"><button type="button" id="save" onclick="submitForm(0)">保存</button></div></div></li>
<!-- 		       <li><div class="buttonActive"><div class="buttonContent"><button type="button" id="saveWj" onclick="submitForm('wjdd')">完结订单</button></div></div></li> -->
		       <li><div class="buttonActive"><div class="buttonContent"><button type="button" id="save1" onclick="submitForm(1)">直接提交</button></div></div></li>
		       <webres:displaycontroller elementId="CGPOWARE_BH_CHEECK_PH" description="采购入库驳回">
		       		<li><div class="buttonActive"><div class="buttonContent"><button type="button" id="bohui" onclick="submitForm('bh')">驳回</button></div></div></li>
		      	</webres:displaycontroller>
		       <webres:displaycontroller elementId="CGPOWARE_YJ_CHEECK" description="采购入库二级审核">
		       			<li><div class="buttonActive"><div class="buttonContent"><button type="button" id="save2" onclick="submitForm(2)">二级审核</button></div></div></li>
		       			<li><div class="buttonActive"><div class="buttonContent"><button type="button" id="savej2" onclick="submitForm(3)">二级审核完结</button></div></div></li>
		      		</webres:displaycontroller>
		      		<webres:displaycontroller elementId="CGPOWARE_EJ_CHEECK" description="采购入库三级审核">
		       			<li><div class="buttonActive"><div class="buttonContent"><button type="button" id="save3" onclick="submitForm(3)">三级审核</button></div></div></li>
		      		</webres:displaycontroller>
		       <li><div class="button"><div class="buttonContent"><button type="button" class="print" onclick="CloseDialog()">关闭</button></div></div></li>
	        </ul>
        </div>
    </div>
</form>
</body>
</html>
